<%--
  Created by IntelliJ IDEA.
  User: gg
  Date: 14-5-4
  Time: 下午4:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="page-header no-padding">
    <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons ">
        <button class="btn btn-xs btn-primary add_button" id="pUser_add_button">
            <i class="icon-zoom-in bigger-130"></i>
            添加
        </button>
        <button class="btn btn-xs btn-danger remove_button" id="pUser_remove_button">
            <i class="icon-trash bigger-130"></i>
            删除
        </button>
    </div>
</div>
<!-- /.page-header -->

<div class="table-responsive">
    <table id="pRole_table" class="table table-striped table-bordered table-hover table-condensed"
           url="${ctx}/pRole/index.do">
        <thead>
        <tr>
            <th class="center">
                <label>
                    <input type="checkbox" class="ace"/>
                    <span class="lbl"></span>
                </label>
            </th>
            <th>角色名称</th>
            <th>创建人</th>
            <th>创建时间</th>
            <th>更新人</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${list}" var="bean" varStatus="status">
            <tr>
                <td class="center">
                    <label>
                        <input type="checkbox" class="ace" name="id" value="${bean.id}"/>
                        <span class="lbl"></span>
                    </label>
                </td>
                <td><a href="#">${bean.name}</a></td>
                <td> ${bean.createTime}</td>
                <td> ${bean.createUser}</td>
                <td> ${bean.updateTime}</td>
                <td> ${bean.updateUser}</td>
                <td>
                    <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">

                        <a class="blue view_button" href="#">
                            <i class="icon-check bigger-130"></i>
                        </a>

                        <a class="green edit_button" href="#">
                            <i class="icon-pencil bigger-130"></i>
                        </a>

                        <a class="red remove_one_button" href="#">
                            <i class="icon-trash bigger-130"></i>
                        </a>
                    </div>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<!-- /.table-responsive -->
<jsp:include page="../../page_ajax.jsp"></jsp:include>
<script>
    //pUser_add_button
    $('#pUser_add_button').click(function () {
        window.location.href='${ctx}/pUser/add.do';
    })

    //pUser_remove_button
    $('#pUser_remove_button').click(function () {
        var idArray = tableObj.getTableSelectedIds();
        if (idArray.length == 0) {
            $.initAlert({message: '请至少选择一条记录'});
            return false;
        }
        $.initConfirm("你确定要删除选中的记录吗？", function (c) {
            if (c) {
                $.simpleAjax({url: '${ctx}/pUser/delete.do', data: {ids: idArray.join(',')}, callback: function (data) {
                    $.initAlert({message: data.message,callback:function(){
                        window.location.href='${ctx}/pUser/index.do';
                    }})
                }});
            }
        })
    })

    //edit_button
    $('.edit_button').click(function () {
        var id = $(this).parents('tr').find('input[name=id]').val();
        var urlParams ='?id='+id;
        window.location.href='${ctx}/pUser/edit.do'+urlParams;
    })

    //view_button
    $('.view_button').click(function () {
        var id = $(this).parents('tr').find('input[name=id]').val();
        var urlParams ='?id='+id;
        window.location.href='${ctx}/pUser/view.do'+urlParams;
    })

    //remove_one_button
    $('.remove_one_button').click(function () {
        var id = $(this).parents('tr').find('input[name=id]').val();
        $.initConfirm("你确定要删除选中的记录吗？", function (c) {
            if (c) {
                $.simpleAjax({url: '${ctx}/pUser/delete.do', data: {ids: id}, callback: function (data) {
                    $.initAlert({message: data.message,callback:function(){
                        window.location.href='${ctx}/pUser/index.do';
                    }})
                }});
            }
        })
    })
</script>
